< previous page page_306 next page >

Page 306
7017a6ead0e3c4111b47a554df321e9f.gif
End If
If style& And WS_MAXIMIZE Then
    outstring$ = outstring$ + "WS_MAXIMIZE" + crlf$
End If
If style& And WS_MINIMIZE Then
    outstring$ = outstring$ + "WS_MINIMIZE" + crlf$
End If
If style& And WS_VSCROLL Then
    outstring$ = outstring$ + "WS_VSCROLL" + crlf$
End If
Clearing a Bit
You know that you can set a bit using the OR operation. To set bit 1 you would use
Variable = Variable Or BIT1
How do you clear a bit? Obviously the OR operator won't do the trick.
You could try
Variable = Variable And BIT1
Imagine the variable contained the value 6 when you performed this operation:
6 And BIT1 = 6 And 2 = 0110 (binary) And 0010 (binary) = 0010 = &H2.
This won't do. It clears every bit except for bit 1the opposite of what you want to do. The AND operation can determine if a bit is set, but can it clear a bit?
Yes. Remember, the AND operator can force any bit to 0. The trick is, the mask has to have a 0 for the bit you want to clear, not a 1. And it has to have a 1 for the bits you want to preserve, not a 0. Which operator changes bit values in this way? The NOT operator.
Try this:
6 And (Not BIT1) = 6 And (Not 2) = 0110 And (Not 0010) = 0110 And 1101 = 0100 = &H4.
Bit 1 has been successfully cleared!

 
< previous page page_306 next page >